home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 April: Mac OS SDK / Dev.CD Apr 97 SDK1.toast / Development Kits (Disc 1) / Interfaces&Libraries / Interfaces / PInterfaces / WorldScript.p < prev   
Encoding:
Text File  |  1995-07-06  |  9.4 KB  |  374 lines  |  [TEXT/MPS ]

  1. {
  2.      File:        WorldScript.p
  3.  
  4.      Contains:    WorldScript I Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Package:    Universal Interfaces 2.1 in “MPW Latest” on ETO #18
  8.  
  9.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs@applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. }
  19.  
  20. {$IFC UNDEFINED UsingIncludes}
  21. {$SETC UsingIncludes := 0}
  22. {$ENDC}
  23.  
  24. {$IFC NOT UsingIncludes}
  25.  UNIT WorldScript;
  26.  INTERFACE
  27. {$ENDC}
  28.  
  29. {$IFC UNDEFINED __WORLDSCRIPT__}
  30. {$SETC __WORLDSCRIPT__ := 1}
  31.  
  32. {$I+}
  33. {$SETC WorldScriptIncludes := UsingIncludes}
  34. {$SETC UsingIncludes := 1}
  35.  
  36.  
  37. {$IFC UNDEFINED __TYPES__}
  38. {$I Types.p}
  39. {$ENDC}
  40. {    ConditionalMacros.p                                            }
  41.  
  42. {$IFC UNDEFINED __TRAPS__}
  43. {$I Traps.p}
  44. {$ENDC}
  45.  
  46. {$IFC UNDEFINED __QUICKDRAWTEXT__}
  47. {$I QuickdrawText.p}
  48. {$ENDC}
  49. {    MixedMode.p                                                    }
  50.  
  51. {$PUSH}
  52. {$ALIGN MAC68K}
  53. {$LibExport+}
  54.     
  55. TYPE
  56.     WSIOffset = UInt16;
  57.  
  58.     WSIByteCount = UInt8;
  59.  
  60.     WSIByteIndex = UInt8;
  61.  
  62. { offset from start of sub-table to row in state table }
  63.     WSIStateOffset = UInt16;
  64.  
  65.     WSITableOffset = UInt32;
  66.  
  67.     WSISubtableOffset = UInt16;
  68.  
  69.     WSIGlyphcode = UInt16;
  70.  
  71.     WSITableIdentifiers = UInt32;
  72.  
  73.  
  74. CONST
  75.     kScriptSettingsTag            = 'info';
  76.     kMetamorphosisTag            = 'mort';
  77.     kGlyphExpansionTag            = 'g2g#';
  78.     kPropertiesTag                = 'prop';
  79.     kJustificationTag            = 'kash';
  80.     kCharToGlyphTag                = 'cmap';
  81.     kGlyphToCharTag                = 'pamc';
  82.     kFindScriptRunTag            = 'fstb';
  83.  
  84. {***             L O O K U P    T A B L E    T Y P E S        ***}
  85.     WSILookupSimpleArray        = 0;                            { a simple array indexed by glyph code }
  86.     WSILookupSegmentSingle        = 2;                            { segment mapping to single value }
  87.     WSILookupSegmentArray        = 4;                            { segment mapping to lookup array }
  88.     WSILookupSingleTable        = 6;                            { sorted list of glyph, value pairs }
  89.     WSILookupTrimmedArray        = 8;                            { a simple trimmed array indexed by glyph code }
  90.  
  91.     
  92. TYPE
  93.     WSILookupTableFormat = INTEGER;
  94.  
  95.     WSILookupValue = INTEGER;
  96.  
  97. { An offset from the beginning of the lookup table }
  98.     WSILookupOffset = INTEGER;
  99.  
  100. {    FORMAT SPECIFIC DEFINITIONS }
  101. {
  102.         lookupSimpleArray:
  103.         
  104.         This is a simple array which maps all glyphs in the font
  105.         to lookup values.
  106.     }
  107.     WSILookupArrayHeader = RECORD
  108.         lookupValues:            ARRAY [0..0] OF WSILookupValue;            { The array of values indexed by glyph code }
  109.     END;
  110.  
  111. {
  112.         lookupTrimmedArray:
  113.         
  114.         This is a single trimmed array which maps a single range
  115.         of glyhs in the font to lookup values.
  116.     }
  117.     WSILookupTrimmedArrayHeader = RECORD
  118.         firstGlyph:                WSIGlyphcode;
  119.         limitGlyph:                WSIGlyphcode;
  120.         valueArray:                ARRAY [0..0] OF WSILookupValue;
  121.     END;
  122.  
  123. { The format specific part of the subtable header }
  124.     WSILookupFormatSpecificHeader = RECORD
  125.         CASE INTEGER OF
  126.         0: (
  127.             lookupArray:                WSILookupArrayHeader;
  128.            );
  129.         1: (
  130.             trimmedArray:                WSILookupTrimmedArrayHeader;
  131.            );
  132.     END;
  133.  
  134. { The overall subtable header }
  135.     WSILookupTableHeader = RECORD
  136.         format:                    WSILookupTableFormat;                    { table format }
  137.         fsHeader:                WSILookupFormatSpecificHeader;            { format specific header }
  138.     END;
  139.  
  140. {***        G L Y P H    E X P A N S I O N    ***}
  141.  
  142. CONST
  143. { fixed 1.0 }
  144.     kCurrentGlyphExpansionVersion = $00010000;
  145.  
  146.     
  147. TYPE
  148.     GlyphExpansionFormats = INTEGER;
  149.  
  150.  
  151. CONST
  152.     GlyphExpansionLookupFormat    = 1;
  153.     GlyphExpansionContextualFormat = 2;
  154.  
  155.  
  156. TYPE
  157.     ExpandedGlyphCluster = PACKED RECORD
  158.         numGlyphs:                WSIByteCount;
  159.         bestGlyph:                WSIByteIndex;
  160.         glyphs:                    ARRAY [0..0] OF WSIGlyphcode;
  161.     END;
  162.  
  163.     ExpandedGlyphOffset = RECORD
  164.         glyph:                    WSIGlyphcode;
  165.         offset:                    WSIOffset;                                { offset to ExpandedGlyphCluster }
  166.     END;
  167.  
  168.     GlyphExpansionStateTable = RECORD
  169.         stateTableOffset:        WSISubtableOffset;
  170.         classTableOffset:        WSISubtableOffset;
  171.         actionTableOffset:        WSISubtableOffset;                        { state, class and actions tables follow here... }
  172.     END;
  173.  
  174.     GlyphExpansionTable = RECORD
  175.         version:                Fixed;
  176.         format:                    INTEGER;
  177.         expansionNumer:            INTEGER;
  178.         expansionDenom:            INTEGER;                                { num/denom ratio for expansion <2> }
  179.         CASE INTEGER OF
  180.         0: (
  181.             stateTable:                    GlyphExpansionStateTable;
  182.            );
  183.         1: (
  184.             lookup:                        WSILookupTableHeader;                { expanded glyph clusters follow here... }
  185.            );
  186.     END;
  187.  
  188. { Glyph-to-Character constants and types  }
  189.  
  190. CONST
  191.     kCurrentGlyphToCharVersion    = $00010100;
  192.  
  193.     
  194. TYPE
  195.     GlyphToCharLookupFormats = INTEGER;
  196.  
  197.  
  198. CONST
  199.     kGlyphToCharLookup8Format    = 1;
  200.     kGlyphToCharLookup16Format    = 2;
  201.     kGlyphToCharLookup32Format    = 3;
  202.  
  203.     
  204. TYPE
  205.     GlyphToCharFontIndex = UInt8;
  206.  
  207.     QDGlyphcode = UInt8;
  208.  
  209.     GlyphToCharActionTable = RECORD
  210.         fontNameOffset:            WSISubtableOffset;                        { offset relative to this table }
  211.         actions:                WSILookupTableHeader;                    { only support lookupSimpleArray format for now }
  212.     END;
  213.  
  214.     GlyphToCharActionHeader = RECORD
  215.         numTables:                INTEGER;                                { 0..n }
  216.         offsets:                ARRAY [0..0] OF WSISubtableOffset;        { offsets from start of action table header }
  217.     END;
  218.  
  219.     GlyphToCharHeader = RECORD
  220.         version:                Fixed;
  221.         actionOffset:            WSISubtableOffset;                        { offset to GlyphToCharActionHeader }
  222.         format:                    INTEGER;                                { size of font mask }
  223.         mappingTable:            WSILookupTableHeader;
  224.     END;
  225.  
  226. { JUSTIFICATION TYPES
  227.     WorldScript supports justification of text using insertion. The justification
  228.     table specifies a insertion string to insert between 2 specified glyphs.
  229.     Each combination of inter-glyph boundary can be assigned a justification priority,
  230.     the higher the priority the more justification strings inserted at that position.
  231.     
  232.     The priorities for each inter-glyph boundary are specified by the justification table's
  233.     state table.
  234.     
  235.     Special handling is done for scripts which use spaces to justify, because the width of 
  236.     a space varies depending on the setting of SpaceExtra. This is why the number of spaces
  237.     per inserting string is specified in the justification table.
  238.  
  239. }
  240.  
  241. CONST
  242. { 1.0 not supported }
  243.     kCurrentJustificationVersion = $0200;
  244.  
  245.     kJustificationStateTableFormat = 1;
  246.  
  247. { WSI's internal limitation <12> }
  248.     kMaxJustificationStringLength = 13;
  249.  
  250.     
  251. TYPE
  252.     WSIJustificationPriority = UInt8;
  253.  
  254.  
  255. CONST
  256.     WSIJustificationSetMarkMask    = $80;
  257.  
  258.  
  259. TYPE
  260.     WSIJustificationStateEntry = PACKED RECORD
  261.         markPriority:            WSIJustificationPriority;                { non-zero priorities means insertion }
  262.         priority:                WSIJustificationPriority;
  263.         newState:                WSIStateOffset;
  264.     END;
  265.  
  266.     WSIJustificationClasses = INTEGER;
  267.  
  268.  
  269. CONST
  270.     wsiJustEndOfLineClass        = 0;
  271.     wsiJustEndOfRunClass        = 1;
  272.     wsiJustDeletedGlyphClass    = 2;
  273.     wsiJustUserDefinedClass        = 3;
  274.  
  275.     
  276. TYPE
  277.     WSIJustificationStates = INTEGER;
  278.  
  279.  
  280. CONST
  281.     wsiStartOfLineState            = 0;                            { pre-defined states }
  282.     wsiStartOfRunState            = 1;
  283.     wsiUserDefinedState            = 2;
  284.  
  285. { pre-multiplied: class# * sizeof(WSIJustificationStateEntry) }
  286.     
  287. TYPE
  288.     WSIJustificationClassOffset = UInt8;
  289.  
  290.     WSIJustificationStateTable = RECORD
  291.         maxPriorities:            INTEGER;
  292.         rowWidth:                INTEGER;                                { width of a state table row in bytes }
  293.         classTableOffset:        INTEGER;
  294.         stateTableOffset:        INTEGER;
  295.     END;
  296.  
  297.     WSIJustificationHeader = RECORD
  298.         version:                INTEGER;
  299.         format:                    INTEGER;
  300.         scaling:                Point;                                    { numer/denom scaling of priority weights <7> }
  301.         spacesPerInsertion:        INTEGER;                                { # of $20 chars in justification insertion string <12> }
  302.         justStringOffset:        INTEGER;                                { offset to justification string }
  303.         stateTable:                WSIJustificationStateTable;                { long-aligned boundary aligned w/ spacesPerInsertion field - justification string follows }
  304.     END;
  305.  
  306. { Line Layout's Property table version <11> }
  307.  
  308. CONST
  309. { v1.0 }
  310.     currentPropsTableVersion    = $00010000;
  311.  
  312. { ??? is this right }
  313.     kCharToGlyphCurrentVersion    = 0100;
  314.  
  315. { pass as priorityWeight to JustifyWSILayout to use script's current just setting }
  316.     kScriptsDefaultJustWeight    = -1;
  317.  
  318.  
  319. TYPE
  320.     WSIGlyphInfoRec = RECORD
  321.         qdChar:                    SInt8; (* UInt8 *)
  322.         rightToLeft:            SInt8;                                    { !0 means rightToLeft, 0 means leftToRight }
  323.         fontID:                    INTEGER;
  324.         originalOffset:            INTEGER;                                { or negative original offset if not in original text input }
  325.         unused:                    INTEGER;                                { long-align }
  326.     END;
  327.  
  328.     WSIGlyphInfoRecPtr = ^WSIGlyphInfoRec;
  329.     WSIGlyphInfoHandle = ^WSIGlyphInfoRecPtr;
  330.  
  331.     WSILayoutHandle = Handle;
  332.  
  333.  
  334. FUNCTION NewWSILayout(layoutH: WSILayoutHandle; text: Ptr; txLength: INTEGER; lineDirection: INTEGER; flags: LONGINT; VAR err: OSErr): WSILayoutHandle;
  335.     {$IFC NOT GENERATINGCFM}
  336.     INLINE $2F3C, $8414, $0040, $A8B5;
  337.     {$ENDC}
  338. FUNCTION JustifyWSILayout(layoutH: WSILayoutHandle; slop: Fixed; priorityWeight: INTEGER; styleRunPosition: JustStyleCode; numer: Point; denom: Point; VAR err: OSErr): WSILayoutHandle;
  339.     {$IFC NOT GENERATINGCFM}
  340.     INLINE $2F3C, $8418, $0042, $A8B5;
  341.     {$ENDC}
  342. FUNCTION MeasureWSILayout(layoutH: WSILayoutHandle; numer: Point; denom: Point): Fixed;
  343.     {$IFC NOT GENERATINGCFM}
  344.     INLINE $2F3C, $840C, $0044, $A8B5;
  345.     {$ENDC}
  346. PROCEDURE DrawWSILayout(layoutH: WSILayoutHandle; numer: Point; denom: Point);
  347.     {$IFC NOT GENERATINGCFM}
  348.     INLINE $2F3C, $800C, $0046, $A8B5;
  349.     {$ENDC}
  350. { "low-level" routines }
  351. FUNCTION GetWSILayoutParts(layoutH: WSILayoutHandle; destH: WSIGlyphInfoHandle; VAR numGlyphs: INTEGER; VAR err: OSErr): WSIGlyphInfoHandle;
  352.     {$IFC NOT GENERATINGCFM}
  353.     INLINE $2F3C, $8410, $0048, $A8B5;
  354.     {$ENDC}
  355. PROCEDURE DrawWSIGlyphs(length: INTEGER; qdCodes: Ptr; numer: Point; denom: Point);
  356.     {$IFC NOT GENERATINGCFM}
  357.     INLINE $2F3C, $800E, $004A, $A8B5;
  358.     {$ENDC}
  359. FUNCTION xMeasureWSIGlyphs(VAR qdCodes: Ptr; length: INTEGER; numer: Point; denom: Point): Fixed;
  360.     {$IFC NOT GENERATINGCFM}
  361.     INLINE $2F3C, $840E, $004C, $A8B5;
  362.     {$ENDC}
  363.  
  364. {$ALIGN RESET}
  365. {$POP}
  366.  
  367. {$SETC UsingIncludes := WorldScriptIncludes}
  368.  
  369. {$ENDC} {__WORLDSCRIPT__}
  370.  
  371. {$IFC NOT UsingIncludes}
  372.  END.
  373. {$ENDC}
  374.